/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.CountDownLatch;

/**
 * <p>Project: app2022 - T25
 * <p>Powered by webrx On 2022-02-07 17:25:57
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T25 {
    static int i = 0;
    static CountDownLatch c = new CountDownLatch(1000000);

    public static void main(String[] args) {
        long s = System.currentTimeMillis();
        System.out.println(s);
        var t = new T25();
        for (int i1 = 0; i1 < 1000000; i1++) {
            new Thread(t::add).start();
        }

        try {
            c.await();
            System.out.println(i);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(System.currentTimeMillis() - s);


    }

    synchronized void add() {
        ++i;
        c.countDown();
    }
}
